
import Vue from 'vue'

let page = {
  total: 1,
  startIndex: 0,
  stepNumber: 40,
  currentPage: 1
};

let data={
  productList:[],
  categoryList:[]
}
let status={
}
let params={
  operation:"0",
  productCode:'',
  productName:"",
  selectedClassification:'',
  selection:[],
  state:"0",
  sort:""
}
let table = {
  tableTitles: {
    columnSelection: {
      type: 'selection',
      width: 55,
      align: 'center',
      fixed: 'left'
    },
    index :{
      type: 'index',
      title: '#',
      width: 70,
      key: 'index',
      fixed: 'left',
      align: 'center',
    },
    columnCode: {
      title: 'SKU',
      key: 'code',
      width: 170,
      align: 'center',
      render: (h, params) => {
        var productUrl = Vue.prototype.$tiyProductUrl(params.row.code);
        return h('div',[h('a',{
          attrs:{href:productUrl,target:'_blank'}
        },params.row.code)]);
      }
    },
    columnImg: {
      title: '产品图片',
      key: 'listImgUrl',
      width: 160,
      height:100,
      render: (h, params) => {
        let yunPath = Vue.prototype.$store.getters.imgPrefix;
        let imageUrl = params.row.productImg;
        return !imageUrl ? '' : h('img', {
          attrs: {src: imageUrl, height: 60},
          on: {
            click: () => {
              status.modalImage.url = imageUrl;
              status.modalImage.isShow = true;
            }
          }
        })
      },
      align: 'center'
    },
   productName: {
    title: '产品名',
      key: 'name',
    // width: 100,
    align: 'left'
    },
    columnPrice: {
      title: '价格($)',
      width: 120,
      key: 'current_price',
      align: 'center',
      render: (h, params) => {
        if(params.row.suggestedPrice===params.row.currentPrice){
          return  h('div',[h('strong', {style: {}}, params.row.currentPrice)]);
        }else{
          return h('div',
            [h('s', {color: "#fafafa", style: {fontSize: "8px", marginRight: '10px',fontStyle:'italic',color:'#bdbdbd'}}, params.row.suggestedPrice),
              h('strong', {style: {}}, params.row.currentPrice)]);
        }

      },
    },
    columnState: {
      title: '状态',
      key: 'state',
      width: 110,
      render: (h, params) => {
        let state = '';
        let color = 'green';
        switch(params.row.state){
          case 0:
            state = '已上架';
            break;
          case -1:
            state = '已下架';
            color='magenta';
            break;
          case -2:
            state = '回收站';
            color='cyan';
            break;
          case 3:
            state = '未上架';
            color='magenta'
            break;
          default:
            break;
        }
        return (
          <div>
            <tag color={color}>{state}</tag>
          </div>
        );
      },
      align: 'center'
    },
    columnCreateTime: {
      title: '创建时间',
      width: 160,
      key: 'createtime',
      align: 'center',
      sortable: 'custom',
      render: (h, params) => {
        return h('div',self.$tiyBJTime(params.row.createtime));
      },
    },
  }
}

export  default  {
  tPage: page,
  tStatus: status,
  tParam: params,
  tData: data,
  tTable: table,
};

